using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Xeml.Sampling;

namespace Xid.Controls
{
    public partial class AuthRequestForm : Form
    {

        private AuthenticationRequestEventArgs authArgs;
        private string providerName;

        public string ProviderName
        {
            get { return this.kryptonHeaderGroup1.ValuesSecondary.Heading; }
            set { this.kryptonHeaderGroup1.ValuesSecondary.Heading = value; }
        }


        public AuthenticationRequestEventArgs AuthArgs
        {
            get { return authArgs; }
            set 
            { 
                authArgs = value;
                if (value != null)
                {
                    textBoxUser.DataBindings.Add("Text", authArgs, "UserName", false, DataSourceUpdateMode.Never);
                    textBoxPasswd.DataBindings.Add("Text", authArgs, "Password", false, DataSourceUpdateMode.Never);
                }
            }
        }


        public AuthRequestForm()
        {
            InitializeComponent();
            buttonSpecClose.Click += new EventHandler(OnCancel);
        }

       

        private void OnCancel(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
            authArgs.Cancel = true;
            this.Close();
        }

        private void OnOk(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.OK;
            if (authArgs != null)
            {
                textBoxUser.DataBindings["Text"].ControlUpdateMode = ControlUpdateMode.Never;
                textBoxPasswd.DataBindings["Text"].ControlUpdateMode = ControlUpdateMode.Never;
                textBoxUser.DataBindings["Text"].WriteValue();
                textBoxPasswd.DataBindings["Text"].WriteValue();
            }
            this.Close();
        }
    }
}